<?php
/*
	自提点中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['ischecklogin']=cfc('core')->checklogin('','',true);
	$return['setting']=$this->plugin_setting('page');
	$return['area_diantitle']=$return['setting']['area_diantitle'];
	$member=$this->get('agent',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	$member['levelname']=$this->getcolumn('level',array('id'=>$member['level_id']),'title');
	$member['levelname']=$member['levelname']?:'默认等级';
	$member['member_num']=pdo_count('jy_area_dian_member',array('dian_id'=>$member['id']));
	$return['member']=$member;
	$team=$this->get('agent',array('uniacid'=>$_SESSION['uniacid'],'id'=>$member['fromuser']));
	$return['team']=$team;
	$data=array();
	//已结算佣金
	$data['balance_total']=$this->sum('balance',array('mid'=>$_SESSION['uid']),'money');
	$data['balance_num']=$this->count('balance',array('mid'=>$_SESSION['uid']));
	//待结算佣金
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1);
	/*if($this->setting['balance_day']){
		//结算天数
		$time=TIMESTAMP-intval($this->setting['balance_day'])*86400;
		$params['complete_time <']=$time;
	}*/
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$data['commission_1']=$this->sum('commission',$params,'money');
	$data['commission_total']=$this->sum('commission',array('uniacid'=>$_SESSION['uniacid'],'dian_id'=>$member['id']),'money');
	$data['commission_num']=$this->count('commission',array('uniacid'=>$_SESSION['uniacid'],'dian_id'=>$member['id']),'id');
	$data['area_num']=$this->count('agent',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$data['ordernum']=$this->count('order',array('uniacid'=>$_SESSION['uniacid'],'dian_id'=>$member['id']));
	$data['dayordernum']=$this->count('order',array('uniacid'=>$_SESSION['uniacid'],'dian_id'=>$member['id'],'createtime >'=>$daytime));
	$data['dayorderfee']=$this->sum('order',array('uniacid'=>$_SESSION['uniacid'],'dian_id'=>$member['id'],'createtime >'=>$daytime),'order_price');
	$data['daytotal']=$this->sum('order',array('uniacid'=>$_SESSION['uniacid'],'dian_id'=>$member['id'],'createtime >'=>$daytime),'total');
	$data['alltotal']=$this->sum('order',array('uniacid'=>$_SESSION['uniacid'],'dian_id'=>$member['id']),'total');
	$data['ordernum0']=$this->count('order',array('status <>'=>3,'uniacid'=>$_SESSION['uniacid'],'dian_id'=>$member['id']));
	$data['ordernum2']=$this->count('order',array('status'=>3,'uniacid'=>$_SESSION['uniacid'],'dian_id'=>$member['id']));
	$return['data']=$data;
	set_html('title',$return['setting']['center']);
	exi($return);
}

?>